import Vue from 'vue'

/**
 *  创建图片预览
 * @param Component 组件实例的选项对象
 * @param props 组件实例中的prop
 */
export function createGlobalComponent(Component, props) {
  const comp = new (Vue.extend(Component))({ propsData: props }).$mount()

  document.body.appendChild(comp.$el)

  comp.remove = () => {
    document.body.removeChild(comp.$el)

    comp.$destroy()
  }

  return comp
}
